-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[improve]Improve the hard code in CDC whole database synchronization #443
Conversation
b76df27
to
0a6bf96
Compare
case DatabaseSyncConfig.SCAN_STARTUP_MODE_VALUE_INITIAL: | ||
mongoDBSourceBuilder.startupOptions(StartupOptions.initial()); | ||
break; | ||
case LATEST_OFFSET_MODE: | ||
case DatabaseSyncConfig.SCAN_STARTUP_MODE_VALUE_LATEST_OFFSET: | ||
mongoDBSourceBuilder.startupOptions(StartupOptions.latest()); | ||
break; | ||
case TIMESTAMP_MODE: | ||
case DatabaseSyncConfig.SCAN_STARTUP_MODE_VALUE_TIMESTAMP: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use cdc variables directly here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These parameters of flink-cdc cannot be directly referenced because they are also privately defined.
DEFAULT_PROPS.setProperty(DatabaseSyncConfig.CONVERTERS, DatabaseSyncConfig.DATE); | ||
DEFAULT_PROPS.setProperty( | ||
"date.type", "org.apache.doris.flink.tools.cdc.mysql.DateToStringConverter"); | ||
DEFAULT_PROPS.setProperty("date.format.date", "yyyy-MM-dd"); | ||
DEFAULT_PROPS.setProperty("date.format.datetime", "yyyy-MM-dd HH:mm:ss.SSSSSS"); | ||
DEFAULT_PROPS.setProperty("date.format.timestamp", "yyyy-MM-dd HH:mm:ss.SSSSSS"); | ||
DEFAULT_PROPS.setProperty("date.format.timestamp.zone", "UTC+8"); | ||
DatabaseSyncConfig.DATE_TYPE, | ||
"org.apache.doris.flink.tools.cdc.mysql.DateToStringConverter"); | ||
DEFAULT_PROPS.setProperty( | ||
DatabaseSyncConfig.DATE_FORMAT_DATE, DatabaseSyncConfig.YEAR_MONTH_DAY_FORMAT); | ||
DEFAULT_PROPS.setProperty( | ||
DatabaseSyncConfig.DATE_FORMAT_DATETIME, DatabaseSyncConfig.DATETIME_MICRO_FORMAT); | ||
DEFAULT_PROPS.setProperty( | ||
DatabaseSyncConfig.DATE_FORMAT_TIMESTAMP, DatabaseSyncConfig.DATETIME_MICRO_FORMAT); | ||
DEFAULT_PROPS.setProperty( | ||
DatabaseSyncConfig.DATE_FORMAT_TIMESTAMP_ZONE, DatabaseSyncConfig.TIME_ZONE_UTC_8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is only used here, I think it is better to define it inside this convert class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each source corresponds to a DateConverter, which basically contains these parameters.
props, | ||
DatabaseSyncConfig.FORMAT_DATE, | ||
p -> dateFormatter = DateTimeFormatter.ofPattern(p)); | ||
readProps( | ||
props, | ||
"format.timestamp", | ||
DatabaseSyncConfig.FORMAT_TIME, | ||
p -> timeFormatter = DateTimeFormatter.ofPattern(p)); | ||
readProps( | ||
props, | ||
DatabaseSyncConfig.FORMAT_DATETIME, | ||
p -> datetimeFormatter = DateTimeFormatter.ofPattern(p)); | ||
readProps( | ||
props, | ||
DatabaseSyncConfig.FORMAT_TIMESTAMP, | ||
p -> timestampFormatter = DateTimeFormatter.ofPattern(p)); | ||
readProps(props, "format.timestamp.zone", z -> timestampZoneId = ZoneId.of(z)); | ||
readProps( | ||
props, | ||
DatabaseSyncConfig.FORMAT_TIMESTAMP_ZONE, | ||
z -> timestampZoneId = ZoneId.of(z)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Proposed changes
Issue Number: close #xxx
Problem Summary:
There is a lot of hard code in the code of synchronizing the whole databases. This method can easily lead to inconsistent configurations on both sides. And it brings a very bad experience to subsequent development or code reading.
Checklist(Required)
Further comments
If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...